using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EuropeEngulfed.NET
{
    partial class TransportDialog : Form
    {
        private EuropeEngulfedNETForm.doDisembarkation doDisembarkation;
        private EuropeEngulfedNETForm.cancelSeaMove cancelSeaMove;
        private SeaMoveOperationalMove seaMoveBeingMade;
        private List<PlayingPiece> unitsBeingTransportedList;
        public TransportDialog(MapInfo.RegionID regionTransportedTo, EuropeEngulfedNETForm.doDisembarkation doDisembarkation, EuropeEngulfedNETForm.cancelSeaMove cancelSeaMove, SeaMoveOperationalMove seaMoveBeingMade)
        {
            InitializeComponent();
            this.transportDialogTitleLabel.Text = "Transport To " + Enum.GetName(typeof(MapInfo.RegionID), regionTransportedTo);
            this.doDisembarkation = doDisembarkation;
            this.cancelSeaMove = cancelSeaMove;
            this.seaMoveBeingMade = seaMoveBeingMade;
            this.unitsBeingTransportedlistView.View = View.Tile;
            this.unitsBeingTransportedlistView.TileSize = new Size(PlayingPieceGraphics.GetBlockSize().Width * 2, PlayingPieceGraphics.GetBlockSize().Height * 2);
        }

        private void TransportButton_Click(object sender, EventArgs e)
        {
            this.doDisembarkation();
            this.Close();
        }

        private void unitsBeingTransportedlistView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
            PlayingPieceGraphics.PaintPlayingPiece(e.Graphics, unitsBeingTransportedList[e.ItemIndex], new Point(e.Bounds.Left + (e.Bounds.Width / 2), e.Bounds.Top + (e.Bounds.Height / 2)));
            e.DrawFocusRectangle();
        }

        public void RefreshUnitsBeingTransported()
        {
            unitsBeingTransportedList = seaMoveBeingMade.GetListOfPiecesBeingTransported();
            this.unitsBeingTransportedlistView.Items.Clear();
            foreach (PlayingPiece playingPiece in unitsBeingTransportedList)
            {
                this.unitsBeingTransportedlistView.Items.Add(playingPiece.GetDescription());
            }
            this.Invalidate();
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            cancelSeaMove();
            this.Close();
        }
    }
}